<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : editPage.xsl
    Created on : November 17, 2013, 9:38 AM
    Author     : Liem
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:p="http://xml.netbeans.org/schema/page" exclude-result-prefixes="p"
  version="1.0">
    <xsl:output method="html"/>
    <xsl:param name="pageId"></xsl:param>
    <xsl:param name="webPath"></xsl:param>
    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="p:page">
        <xsl:if test="p:id=$pageId">
            <form action="editPage.action">
                <div class="information-container">
                    <h4>
                        <xsl:value-of select="p:pagename"/>
                    </h4>
                    <p>
                        <xsl:value-of select="p:description"/>
                    </p>
                    <div>Send confession link:
                        <a id="confUrl" target="_blank">
                            <xsl:attribute name="href">
                                <xsl:value-of select="$webPath"/>
                            </xsl:attribute>
                            <xsl:value-of select="$webPath"/>
                        </a>
                    </div>
                    <h4>Page info</h4>
                    <input type="hidden" name="pageId">
                        <xsl:attribute name="value">
                            <xsl:value-of select="p:id"/>
                        </xsl:attribute>
                    </input>
                    <ul class="profile-intro">
                        <li>
                            <label>Page name:</label>
                            <input type="text" name="pagename">
                                <xsl:attribute name="value">
                                    <xsl:value-of select="p:pagename"/>
                                </xsl:attribute>
                            </input>
                        </li>
                        <li>
                            <label>Description:</label>
                            <textarea name="description" rows="6" cols="300">
                                <xsl:value-of select="p:description"/>
                            </textarea>
                        </li>
                        <li>
                            <label>Facebook id:</label>
                            <input type="text" name="fbPageId" value="">
                                <xsl:attribute name="value">
                                    <xsl:value-of select="p:fbPageId"/>
                                </xsl:attribute>
                            </input>
                        </li>
                        <li>
                            <label>Hashtag:</label>
                            <input type="text" name="hashtag">
                                <xsl:attribute name="value">
                                    <xsl:value-of select="p:hashtag"/>
                                </xsl:attribute>
                            </input>
                        </li>
                        <li>
                            <label>Cover Image link:</label>
                            <input type="text" name="imageLink" value="">
                                <xsl:attribute name="value">
                                    <xsl:value-of select="p:imageLink"/>
                                </xsl:attribute>
                            </input>
                        </li>
                    </ul>
                </div>
                <input type="submit" name="Save" value="Save" class="btn btn-extend"/>
                <input type="reset" name="Cancel" value="Cancel" class="btn btn-extend"/>
            </form>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
